<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //【1】with 会将 object 中的所有属性添加到 block 上下文中。
        const Person = {
            firstname: "sky",
            lastname: "moon",
            age: 29
        }
        with(Person) {
            console.log(`${firstname}+${lastname} is ${age} years old`);
            console.log(firstname); //注意这个地方，并没有使用Person.firstname。而是直接使用了属性
        };
    </script>
</body>

</html>